meteorite_data <- read.csv("meteorite-landings.csv")
meteorite_data <- meteorite_data %>%
clean_names() %>%
filter(year >= 1900 & year <= 2013) %>%
select(-fall)
meteorite_data_cleaned <- meteorite_data %>%
filter(!is.na(reclat) & !is.na(reclong)) %>%
filter(!is.na(mass) & !is.na(year))
summary(meteorite_data_cleaned)
## name id nametype recclass
## Length:37408 Min. : 2 Length:37408 Length:37408
## Class :character 1st Qu.:10892 Class :character Class :character
## Mode :character Median :21902 Mode :character Mode :character
## Mean :25552
## 3rd Qu.:40134
## Max. :57458
## mass year reclat reclong
## Min. : 0 Min. :1900 Min. :-87.37 Min. :-165.43
## 1st Qu.: 6 1st Qu.:1986 1st Qu.:-76.72 1st Qu.: 0.00
## Median : 28 Median :1996 Median :-71.50 Median : 35.67
## Mean : 7214 Mean :1993 Mean :-40.93 Mean : 62.66
## 3rd Qu.: 167 3rd Qu.:2003 3rd Qu.: 0.00 3rd Qu.: 157.17
## Max. :60000000 Max. :2013 Max. : 81.17 Max. : 178.20
## geo_location
## Length:37408
## Class :character
## Mode :character
##
##
##
world_map <- map_data("world")
ggplot() +
geom_map(data = world_map, map = world_map, aes(x = long, y = lat, map_id = region), fill = "white", color = "gray") +
geom_point(data = meteorite_data, aes(x = reclong, y = reclat), color = "blue", alpha = 0.5, size = 1) +
labs(title = "Global Distribution of Meteorite Landings (1399-2013)",
x = "Longitude", y = "Latitude")

ggplot(meteorite_data, aes(x = recclass, y = mass)) +
geom_jitter(width = 0.2, height = 0, alpha = 0.5) +
scale_y_log10() +
labs(title = "Meteorite Mass by Type",
x = "Meteorite Type (recclass)", y = "Mass (log scale)") +
theme(axis.text.x = element_text(angle = 90, hjust = 1))

# Count meteorite landings by year
yearly_landings <- meteorite_data %>%
group_by(year) %>%
summarise(count = n())
# Line plot of meteorite landings over the years
ggplot(yearly_landings, aes(x = year, y = count)) +
geom_line(color = "blue") +
labs(title = "Meteorite Landings Over Time",
x = "Year", y = "Number of Meteorite Landings")

fig <- plot_ly(
data = meteorite_data,
type = 'scattermapbox',
lat = ~reclat,
lon = ~reclong,
mode = 'markers',
marker = list(size = 4, color = 'blue', opacity = 0.5),
text = ~paste("Name:", name, "<br>Year:", year, "<br>Mass:", mass)
)
fig <- fig %>%
layout(
title = 'Global Distribution of Meteorite Landings (1399-2013)',
mapbox = list(
style = "carto-positron",
zoom = 1
)
)
fig
yearly_landings <- meteorite_data %>%
group_by(year) %>%
summarise(count = n())
# Line plot with Plotly
fig <- plot_ly(
data = yearly_landings,
x = ~year,
y = ~count,
type = 'scatter',
mode = 'lines',
line = list(color = 'blue')
) %>%
layout(
title = 'Meteorite Landings Over Time',
xaxis = list(title = 'Year'),
yaxis = list(title = 'Number of Meteorite Landings')
)
fig